'''
Created on Apr 17, 2010

@author: darkelf
'''
import compiler

class BasicElement(object):
    
    def __init__(self):
        self.childs = []
        self.attributes = {}
        self.element_name = ""
        self.has_end_tag = True
        
    def set_content(self, content):
        b_text = BasicText()
        b_text.set_content(content)
        self.childs.append(b_text)
        
    def append_function(self, source):
        mod = compiler.parse(source)                                    
        func = mod.node.nodes[0]
        
        d = {}
        exec source.strip() in d
        setattr(self.__class__, func.name, d[func.name])       
        
    def detect_functions(self, obj):
        pass
        
    def get_html(self):
        html = "<" + self.element_name + " "
        for attr in self.attributes:
            html+= attr + "=\"" + self.attributes[attr] + "\" "
        
        if len(self.childs) > 0:
            html+= ">"
            for child in self.childs:
                html+= child.get_html()
            if self.has_end_tag:
                html+= "</" + self.element_name + ">"
        else:
            if self.has_end_tag:
                html+= "/>"
            else:
                html+=">"
        return html

class BasicText(object):
    
    def __init__(self):
        self.text_content = ''
    
    def set_content(self, content):
        content = content.replace("\n","").replace("\t","").replace("\r","")
        self.text_content = content
    
    def get_html(self):
        return self.text_content
    
class DFunction:
    
    def __init__(self):
        self.func_name = ''
        self.func_body = ''
    
    def get_html(self):
        return ""
               
    def set_content(self, content):
        content = content.replace("\r\n","\n")
        result_string = []
        t_count = 0
        wt_count = 0
        def_found = False
        for c in content:
            if def_found:
                if wt_count==t_count:
                    result_string.append(c)
                    if c=='\n':
                        wt_count = 0
                else:
                    wt_count+=1
            else:
                if c=='\n':
                    if len(result_string)>0:
                        def_found = True
                if c=='\t':
                    t_count+=1
                else:
                    result_string.append(c)
        self.func_body = ''.join(result_string)
        
    def detect_functions(self, obj):
        obj.append_function(self.func_body)

class HtmlCoreAttrs(BasicElement):
    
    def __init__(self):
        BasicElement.__init__(self)
        
    def set_id(self,id):
        self.attributes['id'] = id
        
    def set_class(self,_class):
        self.attributes['class'] = _class
        
    def set_style(self,style):
        self.attributes['style'] = style
        
    def set_title(self,title):
        self.attributes['title'] = title
    
class HtmlI18n(BasicElement):
    
    def __init__(self):
        BasicElement.__init__(self)
        
    def set_lang(self,lang):
        self.attributes['lang'] = lang
        
    def set_dir(self,dir):
        self.attributes['dir'] = dir
        
class HtmlEvents(BasicElement):
    
    def __init__(self):
        BasicElement.__init__(self)
        
    def set_onclick(self,onclick):
        self.attributes['onclick'] = onclick
        
    def set_ondblclick(self,ondblclick):
        self.attributes['ondblclick'] = ondblclick
        
    def set_onmousedown(self,onmousedown):
        self.attributes['onmousedown'] = onmousedown
        
    def set_onmouseup(self,onmouseup):
        self.attributes['onmouseup'] = onmouseup
        
    def set_onmouseover(self,onmouseover):
        self.attributes['onmouseover'] = onmouseover
        
    def set_onmousemove(self,onmousemove):
        self.attributes['onmousemove'] = onmousemove
        
    def set_onmouseout(self,onmouseout):
        self.attributes['onmouseout'] = onmouseout
        
    def set_onkeypress(self,onkeypress):
        self.attributes['onkeypress'] = onkeypress
        
    def set_onkeydown(self,onkeydown):
        self.attributes['onkeydown'] = onkeydown
        
    def set_onkeyup(self,onkeyup):
        self.attributes['onkeyup'] = onkeyup
        
class HtmlCellHAlign(BasicElement):
    
    def __init__(self):
        BasicElement.__init__(self)
        
    def set_align(self,align):
        self.attributes['align'] = align
        
    def set_char(self,char):
        self.attributes['char'] = char
        
    def set_charoff(self,charoff):
        self.attributes['charoff'] = charoff
        
class HtmlCellVAlign(BasicElement):
    
    def __init__(self):
        BasicElement.__init__(self)
        
    def set_valign(self,valign):
        self.attributes['valign'] = valign
        
class HtmlAttrGroup(HtmlCoreAttrs,HtmlI18n,HtmlEvents):
    
    def __init__(self):
        HtmlCoreAttrs.__init__(self)
        HtmlI18n.__init__(self)
        HtmlEvents.__init__(self)
                
class HtmlRootObject(HtmlI18n):
    
    def __init__(self):        
        HtmlI18n.__init__(self)
        self.element_name = "html"
        
    def set_version(self,version):
        self.attributes['version'] = version
        
class HtmlHeadObject(HtmlI18n):
    
    def __init__(self):        
        HtmlI18n.__init__(self)
        self.element_name = "head"
        
    def set_profile(self,profile):
        self.attributes['profile'] = profile
        
class HtmlHeadTitleObject(HtmlI18n):
    
    def __init__(self):        
        HtmlI18n.__init__(self)
        self.element_name = "title"
        
class HtmlMetaObject(HtmlI18n):
    
    def __init__(self):        
        HtmlI18n.__init__(self)
        self.element_name = "meta"
        self.has_end_tag = False
    
    def set_name(self,name):
        self.attributes['name'] = name
        
    def set_content(self,content):
        self.attributes['content'] = content
        
    def set_scheme(self,scheme):
        self.attributes['scheme'] = scheme
        
    def set_httpequiv(self,httpequiv):
        self.attributes['http-equiv'] = httpequiv
        
class HtmlBodyObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "body"
        
    def set_onload(self,onload):
        self.attributes['onload'] = onload
        
    def set_onunload(self,onunload):
        self.attributes['onunload'] = onunload
        
    def set_background(self,background):
        self.attributes['background'] = background
        
    def set_text(self,text):
        self.attributes['text'] = text
        
    def set_link(self,link):
        self.attributes['link'] = link
        
    def set_vlink(self,vlink):
        self.attributes['vlink'] = vlink
        
    def set_alink(self,alink):
        self.attributes['alink'] = alink
        
    def set_bgcolor(self,bgcolor):
        self.attributes['bgcolor'] = bgcolor
        
class HtmlDivObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "div"
        
    def set_align(self,align):
        self.attributes['align'] = align
        
class HtmlSpanObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "span"
        
    def set_align(self,align):
        self.attributes['align'] = align
        
class HtmlHeadingObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "h1"
        
    def set_align(self,align):
        self.attributes['align'] = align
        
    def set_heading(self,heading):
        self.element_name = "h" + heading
        
class HtmlAddressObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "address"
        
class HtmlBdoObject(HtmlCoreAttrs,HtmlI18n):
    
    def __init__(self):
        HtmlCoreAttrs.__init__(self)
        HtmlI18n.__init__(self)
        self.element_name = "bdo"
        
class HtmlEmObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "em"

class HtmlStrongObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "strong"
        
class HtmlDfnObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "dfn"
        
class HtmlCodeObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "code"
        
class HtmlSampObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "samp"
        
class HtmlKbdObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "kbd"
        
class HtmlVarObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "var"
        
class HtmlCiteObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "cite"
        
class HtmlAbbrObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "abbr"
        
class HtmlAcronymObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "acronym"
        
class HtmlBlockQuoteObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "blockquote"
        
    def set_cite(self,cite):
        self.attributes['cite'] = cite
        
class HtmlQObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "q"
        
    def set_cite(self,cite):
        self.attributes['cite'] = cite
        
class HtmlSubObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "sub"
        
class HtmlSupObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "sup"
        
class HtmlPObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "p"
        
    def set_align(self,align):
        self.attributes['align'] = align
        
class HtmlBrObject(HtmlCoreAttrs):
    
    def __init__(self):
        HtmlCoreAttrs.__init__(self)
        self.element_name = "br"
        self.has_end_tag = False
        
    def set_clear(self,clear):
        self.attributes['clear'] = clear
        
class HtmlPreObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "pre"
        
    def set_width(self,width):
        self.attributes['width'] = width
        
class HtmlInsObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "ins"
        
    def set_cite(self,cite):
        self.attributes['cite'] = cite
        
    def set_datetime(self,datetime):
        self.attributes['datetime'] = datetime
        
class HtmlDelObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "del"
        
    def set_cite(self,cite):
        self.attributes['cite'] = cite
        
    def set_datetime(self,datetime):
        self.attributes['datetime'] = datetime
        
class HtmlUlObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "ul"
        
    def set_type(self,type):
        self.attributes['type'] = type
        
    def set_compact(self,compact):
        self.attributes['compact'] = compact
        
class HtmlOlObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "ol"
        
    def set_type(self,type):
        self.attributes['type'] = type
        
    def set_compact(self,compact):
        self.attributes['compact'] = compact
        
    def set_start(self,start):
        self.attributes['start'] = start
        
class HtmlLiObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "li"
        
    def set_type(self,type):
        self.attributes['type'] = type
        
    def set_compact(self,compact):
        self.attributes['compact'] = compact
        
    def set_value(self,value):
        self.attributes['value'] = value
        
class HtmlDlObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "dl"
        
class HtmlDtObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "dt"
        
class HtmlDdObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "dd"
        
class HtmlDirObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "dir"
        
class HtmlMenuObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "menu"
        
class HtmlTableObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "table"
        
    def set_summary(self,summary):
        self.attributes['summary'] = summary
        
    def set_width(self,width):
        self.attributes['width'] = width
        
    def set_border(self,border):
        self.attributes['border'] = border
        
    def set_frame(self,frame):
        self.attributes['frame'] = frame
        
    def set_rules(self,rules):
        self.attributes['rules'] = rules
        
    def set_cellspacing(self,cellspacing):
        self.attributes['cellspacing'] = cellspacing
        
    def set_cellpadding(self,cellpadding):
        self.attributes['cellpadding'] = cellpadding
        
    def set_align(self,align):
        self.attributes['align'] = align
        
    def set_bgcolor(self,bgcolor):
        self.attributes['bgcolor'] = bgcolor
        
class HtmlCaptionObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "caption"
        
    def set_align(self,align):
        self.attributes['align'] = align
        
class HtmlTHeadObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "thead"
        
    def set_align(self,align):
        self.attributes['align'] = align
        
    def set_char(self,char):
        self.attributes['char'] = char
        
    def set_charoff(self,charoff):
        self.attributes['charoff'] = charoff
        
    def set_valign(self,valign):
        self.attributes['valign'] = valign
        
class HtmlTFootObject(HtmlAttrGroup,HtmlCellHAlign,HtmlCellVAlign):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        HtmlCellHAlign.__init__(self)
        HtmlCellVAlign.__init__(self)
        self.element_name = "tfoot"
            
class HtmlTBodyObject(HtmlAttrGroup,HtmlCellHAlign,HtmlCellVAlign):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        HtmlCellHAlign.__init__(self)
        HtmlCellVAlign.__init__(self)
        self.element_name = "tbody"
            
class HtmlColGroupObject(HtmlAttrGroup,HtmlCellHAlign,HtmlCellVAlign):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        HtmlCellHAlign.__init__(self)
        HtmlCellVAlign.__init__(self)
        self.element_name = "colgroup"
        
    def set_span(self,span):
        self.attributes['span'] = span
        
    def set_width(self,width):
        self.attributes['width'] = width
        
class HtmlColObject(HtmlAttrGroup,HtmlCellHAlign,HtmlCellVAlign):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        HtmlCellHAlign.__init__(self)
        HtmlCellVAlign.__init__(self)
        self.element_name = "col"
        self.has_end_tag = False
        
    def set_span(self,span):
        self.attributes['span'] = span
        
    def set_width(self,width):
        self.attributes['width'] = width
        
class HtmlTrObject(HtmlAttrGroup,HtmlCellHAlign,HtmlCellVAlign):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        HtmlCellHAlign.__init__(self)
        HtmlCellVAlign.__init__(self)
        self.element_name = "tr"
        
    def set_bgcolor(self,bgcolor):
        self.attributes['bgcolor'] = bgcolor
        
class HtmlThObject(HtmlAttrGroup,HtmlCellHAlign,HtmlCellVAlign):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        HtmlCellHAlign.__init__(self)
        HtmlCellVAlign.__init__(self)
        self.element_name = "th"
        
    def set_bgcolor(self,bgcolor):
        self.attributes['bgcolor'] = bgcolor
        
    def set_abbr(self,abbr):
        self.attributes['abbr'] = abbr
        
    def set_axis(self,axis):
        self.attributes['axis'] = axis
        
    def set_headers(self,headers):
        self.attributes['headers'] = headers
        
    def set_scope(self,scope):
        self.attributes['scope'] = scope
        
    def set_rowspan(self,rowspan):
        self.attributes['rowspan'] = rowspan
        
    def set_colspan(self,colspan):
        self.attributes['colspan'] = colspan
        
class HtmlTdObject(HtmlAttrGroup,HtmlCellHAlign,HtmlCellVAlign):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        HtmlCellHAlign.__init__(self)
        HtmlCellVAlign.__init__(self)
        self.element_name = "td"
        
    def set_bgcolor(self,bgcolor):
        self.attributes['bgcolor'] = bgcolor
        
    def set_abbr(self,abbr):
        self.attributes['abbr'] = abbr
        
    def set_axis(self,axis):
        self.attributes['axis'] = axis
        
    def set_headers(self,headers):
        self.attributes['headers'] = headers
        
    def set_scope(self,scope):
        self.attributes['scope'] = scope
        
    def set_rowspan(self,rowspan):
        self.attributes['rowspan'] = rowspan
        
    def set_colspan(self,colspan):
        self.attributes['colspan'] = colspan
        
class HtmlAObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "a"
        
    def set_charset(self,charset):
        self.attributes['charset'] = charset
        
    def set_type(self,type):
        self.attributes['type'] = type
        
    def set_name(self,name):
        self.attributes['name'] = name
        
    def set_href(self,href):
        self.attributes['href'] = href
        
    def set_hreflang(self,hreflang):
        self.attributes['hreflang'] = hreflang
        
    def set_rel(self,rel):
        self.attributes['rel'] = rel
        
    def set_rev(self,rev):
        self.attributes['rev'] = rev
        
    def set_accesskey(self,accesskey):
        self.attributes['accesskey'] = accesskey
    
    def set_shape(self,shape):
        self.attributes['shape'] = shape
        
    def set_coords(self,coords):
        self.attributes['coords'] = coords
        
    def set_tabindex(self,tabindex):
        self.attributes['tabindex'] = tabindex
        
    def set_onfocus(self,onfocus):
        self.attributes['onfocus'] = onfocus
        
    def set_onblur(self,onblur):
        self.attributes['onblur'] = onblur
        
    def set_target(self,target):
        self.attributes['target'] = target
        
class HtmlLinkObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "link"
        self.has_end_tag = False
        
    def set_charset(self,charset):
        self.attributes['charset'] = charset
        
    def set_href(self,href):
        self.attributes['href'] = href
        
    def set_hreflang(self,hreflang):
        self.attributes['hreflang']
        
    def set_type(self,type):
        self.attributes['type'] = type
        
    def set_rel(self,rel):
        self.attributes['rel'] = rel
        
    def set_rev(self,rev):
        self.attributes['rev'] = rev
        
    def set_media(self,media):
        self.attributes['media'] = media
        
    def set_target(self,target):
        self.attributes['target'] = target
        
class HtmlBaseObject(BasicElement):
    
    def __init__(self):
        BasicElement.__init__(self)
        self.element_name = "base"
        self.has_end_tag = False
        
    def set_href(self,href):
        self.attributes['href'] = href
        
    def set_target(self,target):
        self.attributes['target'] = target
        
class HtmlImgObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "img"
        self.has_end_tag = False
        
    def set_src(self,src):
        self.attributes['src'] = src
        
    def set_alt(self,alt):
        self.attributes['alt'] = alt
        
    def set_longdesc(self,longdesc):
        self.attributes['longdesc'] = longdesc
        
    def set_name(self,name):
        self.attributes['name'] = name
        
    def set_height(self,height):
        self.attributes['height'] = height
        
    def set_width(self,width):
        self.attributes['width'] = width
        
    def set_usemap(self,usemap):
        self.attributes['usemap'] = usemap
        
    def set_ismap(self,ismap):
        self.attributes['ismap'] = ismap
        
    def set_align(self,align):
        self.attributes['align'] = align
        
    def set_border(self,border):
        self.attributes['border'] = border
        
    def set_hspace(self,hspace):
        self.attributes['hspace'] = hspace
        
    def set_vspace(self,vspace):
        self.attributes['vspace'] = vspace
        
class HtmlObjectObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "object"
        
    def set_declare(self,declare):
        self.attributes['declare'] = declare
        
    def set_classid(self,classid):
        self.attributes['classid'] = classid
        
    def set_codebase(self,codebase):
        self.attributes['codebase'] = codebase
        
    def set_data(self,data):
        self.attributes['data'] = data
        
    def set_type(self,type):
        self.attributes['type'] = type
        
    def set_codetype(self,codetype):
        self.attributes['codetype'] = codetype
        
    def set_archive(self,archive):
        self.attributes['archive'] = archive
        
    def set_standby(self,standby):
        self.attributes['standby'] = standby
        
    def set_height(self,height):
        self.attributes['height'] = height
        
    def set_width(self,width):
        self.attributes['width'] = width
        
    def set_usemap(self,usemap):
        self.attributes['usemap'] = usemap
        
    def set_name(self,name):
        self.attributes['name'] = name
        
    def set_tabindex(self,tabindex):
        self.attributes['tabindex'] = tabindex
        
    def set_align(self,align):
        self.attributes['align'] = align
        
    def set_border(self,border):
        self.attributes['border'] = border
        
    def set_hspace(self,hspace):
        self.attributes['hspace'] = hspace
        
    def set_vspace(self,vspace):
        self.attributes['vspace'] = vspace
        
class HtmlParamObject(BasicElement):
    
    def __init__(self):
        BasicElement.__init__(self)
        self.element_name = "param"
        self.has_end_tag = False
        
    def set_id(self, id):
        self.attributes['id'] = id
        
    def set_name(self,name):
        self.attributes['name'] = name
        
    def set_value(self,value):
        self.attributes['value'] = value
        
    def set_valuetype(self,valuetype):
        self.attributes['valuetype'] = valuetype
        
    def set_type(self,type):
        self.attributes['type'] = type
        
class HtmlMapObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "map"
        
    def set_name(self,name):
        self.attributes['name'] = name
        
class HtmlAreaObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "area"
        self.has_end_tag = False
        
    def set_shape(self,shape):
        self.attributes['shape'] = shape
        
    def set_coords(self,coords):
        self.attributes['coords'] = coords
        
    def set_href(self,href):
        self.attributes['href'] = href
        
    def set_nohref(self,nohref):
        self.attributes['nohref'] = nohref
        
    def set_alt(self,alt):
        self.attributes['alt'] = alt
        
    def set_tabindex(self,tabindex):
        self.attributes['tabindex'] = tabindex
        
    def set_accesskey(self,accesskey):
        self.attributes['accesskey'] = accesskey
        
    def set_onfocus(self,onfocus):
        self.attributes['onfocus'] = onfocus
        
    def set_onblur(self,onblur):
        self.attributes['onblur'] = onblur
        
class HtmlStyleObject(HtmlI18n):
    
    def __init__(self):
        HtmlI18n.__init__(self)
        self.element_name = "style"
    
    def set_type(self,type):
        self.attributes['type'] = type
        
    def set_media(self,media):
        self.attributes['media'] = media
        
    def set_title(self,title):
        self.attributes['title'] = title
        
class HtmlTtObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "tt"
        
class HtmlIObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "i"

class HtmlBObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "b"
        
class HtmlBigObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "big"
        
class HtmlSmallObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "small"
        
class HtmlFontObject(HtmlI18n,HtmlCoreAttrs):
    
    def __init__(self):
        HtmlI18n.__init__(self)
        HtmlCoreAttrs.__init__(self)
        self.element_name = "font"
        
    def set_size(self,size):
        self.attributes['size'] = size
        
    def set_color(self,color):
        self.attributes['color'] = color
        
    def set_face(self,face):
        self.attributes['face'] = face
        
class HtmlBaseFontObject(HtmlI18n,HtmlCoreAttrs):
    
    def __init__(self):
        HtmlI18n.__init__(self)
        HtmlCoreAttrs.__init__(self)
        self.element_name = "basefont"
        
    def set_size(self,size):
        self.attributes['size'] = size
        
    def set_color(self,color):
        self.attributes['color'] = color
        
    def set_face(self,face):
        self.attributes['face'] = face
        
class HtmlHrObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "hr"
        
    def set_align(self,align):
        self.attributes['align'] = align
        
    def set_noshade(self,noshade):
        self.attributes['noshade'] = noshade
        
    def set_size(self,size):
        self.attributes['size'] = size
        
    def set_width(self,width):
        self.attributes['width'] = width
        
class HtmlFrameSetObject(HtmlCoreAttrs):
    
    def __init__(self):
        HtmlCoreAttrs.__init__(self)
        self.element_name = "frameset"
        
    def set_rows(self,rows):
        self.attributes['rows'] = rows
        
    def set_cols(self,cols):
        self.attributes['cols'] = cols
        
    def set_onload(self,onload):
        self.attributes['onload'] = onload
        
    def set_onunload(self,onunload):
        self.attributes['onunload'] = onunload
        
class HtmlFrameObject(HtmlCoreAttrs):
    
    def __init__(self):
        HtmlCoreAttrs.__init__(self)
        self.element_name = "frame"
        
    def set_longdesc(self,longdesc):
        self.attributes['longdesc'] = longdesc
        
    def set_name(self,name):
        self.attributes['name'] = name
        
    def set_src(self,src):
        self.attributes['src'] = src
        
    def set_frameborder(self,frameborder):
        self.attributes['frameborder'] = frameborder
        
    def set_marginwidth(self,marginwidth):
        self.attributes['marginwidth'] = marginwidth
        
    def set_marginheight(self,marginheight):
        self.attributes['marginheight'] = marginheight
        
    def set_noresize(self,noresize):
        self.attributes['noresize'] = noresize
        
    def set_scrolling(self,scrolling):
        self.attributes['scrolling'] = scrolling
        
class HtmlNoFramesObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "noframes"
        
class HtmlIFrameObject(HtmlCoreAttrs):
    
    def __init__(self):
        HtmlCoreAttrs.__init__(self)
        self.element_name = "iframe"
        
    def set_longdesc(self,longdesc):
        self.attributes['longdesc'] = longdesc
        
    def set_name(self,name):
        self.attributes['name'] = name
        
    def set_src(self,src):
        self.attributes['src'] = src
        
    def set_frameborder(self,frameborder):
        self.attributes['frameborder'] = frameborder
        
    def set_marginwidth(self,marginwidth):
        self.attributes['marginwidth'] = marginwidth
        
    def set_marginheight(self,marginheight):
        self.attributes['marginheight'] = marginheight
        
    def set_scrolling(self,scrolling):
        self.attributes['scrolling'] = scrolling
        
    def set_align(self,align):
        self.attributes['align'] = align
        
    def set_height(self,height):
        self.attributes['height'] = height
        
    def set_width(self,width):
        self.attributes['width'] = width
        
class HtmlFormObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "form"
        
    def set_action(self,action):
        self.attributes['action'] = action
        
    def set_method(self,method):
        self.attributes['method'] = method
        
    def set_enctype(self,enctype):
        self.attributes['enctype'] = enctype
        
    def set_accept(self,accept):
        self.attributes['accept'] = accept
        
    def set_name(self,name):
        self.attributes['name'] = name
        
    def set_onsubmit(self,onsubmit):
        self.attributes['onsubmit'] = onsubmit
        
    def set_onreset(self,onreset):
        self.attributes['onreset'] = onreset
        
    def set_acceptcharset(self,acceptcharset):
        self.attributes['accept-charset'] = acceptcharset
        
    def set_target(self,target):
        self.attributes['target'] = target
        
class HtmlInputObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "input"
        self.has_end_tag = False
        
    def set_type(self,type):
        self.attributes['type'] = type
        
    def set_name(self,name):
        self.attributes['name'] = name
        
    def set_value(self,value):
        self.attributes['value'] = value
        
    def set_checked(self,checked):
        if checked == "true":
            self.attributes['checked'] = ""
        else:
            del self.attributes['checked']
            
    def set_disabled(self,disabled):
        if disabled == "true":
            self.attributes['disabled'] = ""
        else:
            del self.attributes['disabled']
            
    def set_readonly(self,readonly):
        if readonly == "true":
            self.attributes['readonly'] = ""
        else:
            del self.attributes['readonly']
            
    def set_size(self,size):
        self.attributes['size'] = size
        
    def set_maxlength(self,maxlength):
        self.attributes['maxlength'] = maxlength
        
    def set_src(self,src):
        self.attributes['src'] = src
        
    def set_alt(self,alt):
        self.attributes['alt'] = alt
        
    def set_usemap(self,usemap):
        self.attributes['usemap'] = usemap
        
    def set_ismap(self,ismap):
        self.attributes['ismap'] = ismap
        
    def set_tabindex(self,tabindex):
        self.attributes['tabindex'] = tabindex
        
    def set_accesskey(self,accesskey):
        self.attributes['accesskey'] = accesskey
        
    def set_onfocus(self,onfocus):
        self.attributes['onfocus'] = onfocus
        
    def set_onblur(self,onblur):
        self.attributes['onblur'] = onblur
        
    def set_onselect(self,onselect):
        self.attributes['onselect'] = onselect
        
    def set_onchange(self,onchange):
        self.attributes['onchange'] = onchange
        
    def set_accept(self,accept):
        self.attributes['accept'] = accept
        
class HtmlButtonObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "button"
        
    def set_name(self,name):
        self.attributes['name'] = name
        
    def set_value(self,value):
        self.attributes['value'] = value
        
    def set_type(self,type):
        self.attributes['value'] = type
        
    def set_disabled(self,disabled):
        if disabled == "true":
            self.attributes['disabled'] = ""
        else:
            del self.attributes['disabled']
            
    def set_tabindex(self,tabindex):
        self.attributes['tabindex'] = tabindex
        
    def set_accesskey(self,accesskey):
        self.attributes['accesskey'] = accesskey
        
    def set_onfocus(self,onfocus):
        self.attributes['onfocus'] = onfocus
        
    def set_onblur(self,onblur):
        self.attributes['onblur'] = onblur
        
class HtmlSelectObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "select"
        
    def set_name(self,name):
        self.attributes['name'] = name
        
    def set_size(self,size):
        self.attributes['size'] = size
        
    def set_multiple(self,multiple):
        if multiple == "true":
            self.attributes['multiple'] = ""
        else:
            del self.attributes['multiple']
            
    def set_disabled(self,disabled):
        if disabled == "true":
            self.attributes['disabled'] = ""
        else:
            del self.attributes['disabled']
            
    def set_tabindex(self,tabindex):
        self.attributes['tabindex'] = tabindex
        
    def set_onfocus(self,onfocus):
        self.attributes['onfocus'] = onfocus
        
    def set_onblur(self,onblur):
        self.attributes['onblur'] = onblur
    
    def set_onchange(self,onchange):
        self.attributes['onchange'] = onchange
        
class HtmlOptGroupObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "optgroup"
        
    def set_disabled(self,disabled):
        if disabled == "true":
            self.attributes['disabled'] = ""
        else:
            del self.attributes['disabled']
            
    def set_label(self,label):
        self.attributes['label'] = label
        
class HtmlOptionObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "option"
        
    def set_selected(self,selected):
        if selected == "true":
            self.attributes['selected'] = ""
        else:
            del self.attributes['selected']
            
    def set_disabled(self,disabled):
        if disabled == "true":
            self.attributes['disabled'] = ""
        else:
            del self.attributes['disabled']
            
    def set_label(self,label):
        self.attributes['label'] = label
        
    def set_value(self,value):
        self.attributes['value'] = value
        
class HtmlTextAreaObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "textarea"
        
    def set_name(self,name):
        self.attributes['name'] = name
        
    def set_rows(self,rows):
        self.attributes['rows'] = rows
        
    def set_cols(self,cols):
        self.attributes['cols'] = cols
        
    def set_disabled(self,disabled):
        if disabled == "true":
            self.attributes['disabled'] = ""
        else:
            del self.attributes['disabled']
            
    def set_readonly(self,readonly):
        if readonly == "true":
            self.attributes['readonly'] = ""
        else:
            del self.attributes['readonly']
            
    def set_tabindex(self,tabindex):
        self.attributes['tabindex'] = tabindex
        
    def set_accesskey(self,accesskey):
        self.attributes['accesskey'] = accesskey
        
    def set_onfocus(self,onfocus):
        self.attributes['onfocus'] = onfocus
        
    def set_onblur(self,onblur):
        self.attributes['onblur'] = onblur
        
    def set_onselect(self,onselect):
        self.attributes['onselect'] = onselect
        
    def set_onchange(self,onchange):
        self.attributes['onchange'] = onchange
        
class HtmlLabelObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "label"
        
    def set_for(self,_for):
        self.attributes['for'] = _for
        
    def set_accesskey(self,accesskey):
        self.attributes['accesskey'] = accesskey
        
    def set_onfocus(self,onfocus):
        self.attributes['onfocus'] = onfocus
        
    def set_onblur(self,onblur):
        self.attributes['onblur'] = onblur
        
class HtmlFieldSetObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "fieldset"
        
class HtmlLegendObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "legend"
        
    def set_accesskey(self,accesskey):
        self.attributes['accesskey'] = accesskey
        
class HtmlScriptObject(BasicElement):
    
    def __init__(self):
        BasicElement.__init__(self)
        self.element_name = "script"
        
    def set_charset(self,charset):
        self.attributes['charset'] = charset
        
    def set_type(self,type):
        self.attributes['type'] = type
        
    def set_src(self,src):
        self.attributes['src'] = src
        
    def set_defer(self,defer):
        self.attributes['defer'] = defer
        
class HtmlNoScriptObject(HtmlAttrGroup):
    
    def __init__(self):
        HtmlAttrGroup.__init__(self)
        self.element_name = "noscript"